﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
 
using System.Diagnostics;

namespace AzureReader.BLL
{
    
    
    public class Logger
    {
        /// <summary>
        /// Log the supplied exception using the default logging method specified in the config file
        /// </summary>
        /// <param name="excep"></param>
        public static void LogException(Exception excep)
        {
            
                string strException = ExceptionObjectToString(excep);
                Trace.TraceError(strException);
            
        }
       
             
       

        protected static string ExceptionObjectToString(Exception excep)
        {
            String log = "Exception = " + excep.GetType().ToString() + Environment.NewLine;
            log += "Message = " + excep.Message + Environment.NewLine;
            log += "FullText = " + excep.ToString() + Environment.NewLine;
            log += "Stack Trace= " + excep.StackTrace + Environment.NewLine;
            if (excep.InnerException != null)
                log += ExceptionObjectToString(excep.InnerException);
            return log;
        }

    }
}
